package com.neuedu.shop.controller;


import com.neuedu.shop.entity.Category;
import com.neuedu.shop.service.CategoryService;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author BL
 * @since 2021-04-10
 */
@Controller
@RequestMapping("/category")
public class CategoryController {
    @Resource
    private CategoryService categoryService;

    @RequestMapping(value = "/categories",method = RequestMethod.GET)
    public String selectCategoryAll(ModelMap map){
        map.addAttribute("categories",categoryService.selectList(null));
        return "categories.jsp";
    }
    @RequestMapping(value = "/insertCategory",method = RequestMethod.POST)
    public String insertCategory(Category category){
        categoryService.insertCategory(category);
        return "redirect:categories";
    }

}

